@extends('newAdmin.layout.main')

@section('content')
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">投诉管理</a>
            <a><cite>投诉列表</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
            <i class="layui-icon" style="line-height:30px">ဂ 刷新</i>
        </a>
    </div>
    <div class="x-body">
        <form action="{{url('backstage/complain')}}" class="layui-form layui-col-md12 x-so" method="get">
            {{csrf_field()}}
            <input type="text" name="number" placeholder="运单号" autocomplete="off" class="layui-input">
            <input type="text" name="phone" placeholder="手机号" autocomplete="off" class="layui-input" value=@if(!empty($_GET['phone'])) {{$_GET['phone']}} @endif>
            <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon"></i></button>
        </form>
        <table class="layui-table">
            <thead>
            <tr>
                <th>ID</th>
                <th>运单号</th>
                <th>处理状态</th>
                <th>客户回复状态</th>
                <th>图片内容（点击放大）</th>
                <th>投诉内容</th>
                <th>操作</th>
            </thead>
            <tbody>
            @foreach($complains as $complain)
                <tr>
                    <td>{{$complain->id}}</td>
                    <td>{{$complain->number}}</td>
                    <td>{{$complain->reply_status_text}}</td>
                    <td>{{$complain->status}}</td>
                    <td style="cursor:pointer" onclick="x_admin_show('图片', '{{url("backstage/bigImage", ['id' => $complain->id,'table' => 'complain'])}}')"><image width="20px" src="{{$complain->upload1}}"/> <image width="20px" src="{{$complain->upload2}}"/> <image width="20px" src="{{$complain->upload3}}"/></td>
                    <td>{{$complain->remark}}</td>
                    <td class="td-manage">
                        <a title="回复" onclick="x_admin_show('回复', '{{url("backstage/editComplain", ['id' => $complain->id])}}','600','500')" href="javascript:;">
                            <i class="layui-icon font-24">&#xe642;</i>
                        </a>
                    </td>
                </tr>
            @endforeach
            </tbody>
        </table>
        <div class="page">
            {{$complains->appends(['number' => $_GET['number'] ?? '', 'phone' => $_GET['phone'] ?? ''])->links()}}
        </div>
    </div>
    <script>
        /*广告-禁用*/
        function disable(obj, id){
            layer.confirm('确认要禁用吗？',function(){
                //发异步删除数据
                $.ajax({
                    url: '{{url("backstage/disablecomplain/")}}' + '/' + id,
                    type: 'get',
                    dataType: 'json',
                    data: {},
                    success: function (result) {
                        if (result.status === 0) {
                            $(obj).parents("tr").remove();
                            layer.msg('已禁用!', {icon: 1, time: 1000});
                            location.href = '{{url("backstage/complain")}}';
                            return false;
                        }
                        layer.msg(result.msg);
                        return false;
                    },
                    error: function () {
                        layer.msg('禁用失败，请重试！');
                        return false;
                    }
                });
                return false;
            });
        }

        /*广告-禁用*/
        function enable(obj, id){
            layer.confirm('确认要启用吗？',function(){
                //发异步删除数据
                $.ajax({
                    url: '{{url("backstage/enablecomplain/")}}' + '/' + id,
                    type: 'get',
                    dataType: 'json',
                    data: {},
                    success: function (result) {
                        if (result.status === 0) {
                            $(obj).parents("tr").remove();
                            layer.msg('已启用!', {icon: 1, time: 1000});
                            location.href = '{{url("backstage/complain")}}';
                            return false;
                        }
                        layer.msg(result.msg);
                        return false;
                    },
                    error: function () {
                        layer.msg('启用失败，请重试！');
                        return false;
                    }
                });
                return false;
            });
        }
    </script>
@endsection
